#include<iostream>
#include<vector>
#include<algorithm>
using ll = long long;
const int N = 3e5 + 9;

using namespace std;

const ll inf = 8e18, p = 998888222;

vector<int> X;
ll a[N];
struct Q
{
	ll a, b;
	
}add[N], que[N];

int getidx(ll x)
{
	return lower_bound(X.begin(), X.end(), x) - X.begin() + 1;
}

void solve()
{
	int n, q; cin >> n >> q;
	for (int i = 1; i <= n; ++i)
	{
		ll x, w; cin >> x >> w;
		X.push_back(x);
		add[i] = { x ,w };
	}

	for (int i = 1; i <= q; ++i)
	{
		ll l, r; cin >> l >> r;
		X.push_back(l), X.push_back(r);
		que[i] = { l,r };
	}

	sort(X.begin(), X.end());
	X.erase(unique(X.begin(), X.end()), X.end());

	for (int i = 1; i <= n; ++i)
	{
		int x = getidx(add[i].a);
		ll w = add[i].b;
		a[x] += w;
	}
	for (int i = 1; i <= X.size(); ++i)a[i] += a[i - 1];
	for (int i = 1; i <= q; ++i)
	{
		int l = getidx(que[i].a);
			int r = getidx(que[i].b) ;

		cout << a[r] - a[l - 1] << '\n';

	}
}


int main()
{
	ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);

	int _ = 1;
	while (_--)solve();
	return 0;
}